var gewara = gewara || {}; gewara.util = {};
var GewaraUtil = gewara.util;
gewara.util.onReturn = function(event, action) {
  if (!event) event = window.event;
  if (event && event.keyCode && event.keyCode == 13) action();
};

gewara.util.basePath = '${basePath}';
gewara.util.isNotNull = function(v){
	return (!(v.match(/^\s*$/)));
}
gewara.util.isMobile = function(v) {  
  	return (/^(?:13\d|15[0-9]|18[0-9])-?\d{5}(\d{3}|\*{3})$/.test(v));
}
gewara.util.isEmail = function(v){
	return (/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(v));
}
gewara.util.isVideoURL = function(v){
	var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
	+ "?(([0-9a-z_!~*'().&amp;=+$%-]+: )?[0-9a-z_!~*'().&amp;=+$%-]+@)?" //ftp的user@
	+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
	+ "|" // 允许IP和DOMAIN（域名）
	+ "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
	+ "(tudou|youku|56|ku6)\." // 二级域名
	+ "[a-z]{2,6})" // first level domain- .com or .museum
	+ "(:[0-9]{1,4})?" // 端口- :80
	+ "((/?)|" // a slash isn't required if there is no file name
	+ "(/[0-9a-zA-Z_\/!~*'().;?:@&amp;=+$,%#-]+)+/?)$";
	return new RegExp(strRegex).test(v); 
}
var _debug = function(){
	console.info(arguments);
}

/**
*	该程序验证表单 input 必填域, containerid通常为formID
*	<input type="text" mustTxt="用户名为必填项">	
*/
gewara.util.baseValidForm = function(containerid){
	var vv = $(containerid).getElements('input[mustTxt]');
	try{
		$each(vv, function(i, n){
		var val = $(i).get('value');
		if(!GewaraUtil.isNotNull(val)){
			alert($(i).get('mustTxt'));
			throw "break"; 
		}
	})
	}catch(e){
		if(e != "break") throw e;
		return false;
	}
	return true;
}
gewara.util.mask = function(message, styles) {
	var loadingMessage = message || "正在处理...",
	winSize = $(window).getScrollSize(),
	disabledZone = new Element("div", {
		"id":"disabledZone",
		"styles":{
			"position": "absolute",
			"z-index": "1000",
			"left": "0px",
			"top": "0px",
			"width": winSize.x+"px",
			"height": winSize.y+"px",
			"background-color":"#000"
		}
	}),defaultStyles = {
		"background-color": "red", 
		"color": "white",
		"width":"150px"
	},messageZone = new Element("div",{
		"id":"messageZone",
		"html":loadingMessage,
		"styles": {
			"position":"absolute",
			"top": "0px",
			"left": "0px",
			"padding": "4px",
			"z-index":"1001"
		}
	});
	disabledZone.inject($(document.body));
	messageZone.inject($(document.body));
	gewara.util.toCenter(messageZone);
	disabledZone.setOpacity(0.5);
	gewara.util._disabledZoneUseCount = 1;
	if(styles){
		messageZone.setStyles(styles);
	}else{
		messageZone.setStyles(defaultStyles);
	}
};
/**************
 * remove mask
 **************/
gewara.util.unmask = function() {
	if($("disabledZone")) $("disabledZone").dispose();
	if($("messageZone")) $("messageZone").dispose();
};
gewara.util.Masker = new Class({
   initialize: function(id, mask, options){
   	this.mask=$(mask) || document.body;
   	var size = this.mask.getScrollSize(),
		width=size.x<270?270:size.x,
		height=size.y<70?70:size.y,
		title=options?options.title||"请稍等":"请稍等",
		opacity=options?options.opacity||0:0,
		disableZone = new Element("div",{
			"id":"disableZone"+id,
			"title":title,
			"styles": {
				"width":width+"px",
				"height":height+"px",
				"text-align":"center",
				"visibility":"hidden",
				"position":"absolute",
				"top": "0px",
				"left": "0px",
				"padding": "4px",
				"z-index":"11300"
			}
		}), picZone = new Element("img",{
			"id":"picZone",
			"src":GewaraUtil.basePath+"css/home/home_loading.gif",
			"styles": {
				"display":"block",
				"position":"absolute",
				"top": "0px",
				"left": "0px",
				"visibility":"hidden",
				"padding": "4px",
				"z-index":"11303"
			}
		});
		this.picZone = picZone;
		this.picZone.inject($(document.body));
		if(opacity>0) {
			disableZone.setStyle("background", "black");
			disableZone.setOpacity(opacity);
		}
		
		this.disableZone = disableZone;
		this.disableZone.inject($(document.body));
   },
   show: function(){
		gewara.util.toCenter(this.disableZone, this.mask);
		gewara.util.toCenter(this.picZone, this.mask);
		return this;
   },
   hide: function(){
   	this.disableZone.setStyle("visibility","hidden");
   	this.picZone.setStyle("visibility","hidden");
   },
   clear: function(){
   	this.disableZone.dispose();
   	this.picZone.dispose();
   }
});

gewara.util.getMasker = function(id, mask, options){
	return new gewara.util.Masker(id, mask, options);
};

gewara.util.showLoading = function(target){
	if(!$("loadingPic")){
		var picZone = new Element("img",{
			"id":"loadingPic",
			"src":GewaraUtil.basePath+"css/home/loading.gif",
			"styles": {
				"display":"block",
				"position":"absolute",
				"top": "0px",
				"left": "0px",
				"visibility":"hidden",
				"padding": "4px",
				"z-index":"401"
			}
		});
		picZone.inject(document.body);
	}
	gewara.util.toCenter("loadingPic", target);
};

gewara.util.hideLoading = function(){
	if($("loadingPic")) $("loadingPic").setStyle("visibility","hidden");
}

gewara.util.showDialog = function(el, zIndex, pin){
	if(!zIndex) zIndex = $(el).getStyle("z-index");
	if(zIndex < 10) zIndex = 200;
	var disabledZone = $("dialogDisabledZone"),
	winSize = $(window).getScrollSize();
	if(!disabledZone){
		disabledZone = new Element("div", {
			"id":"dialogDisabledZone",
			"styles":{
				"position": "absolute",
				"z-index": zIndex - 1,
				"left": "0px",
				"top": "0px",
				"background-color":"#000"
			}
		});
		disabledZone.inject($(document.body));
	}
	disabledZone.setStyles({
		"width": winSize.x+"px",
		"height": winSize.y+"px",
		"visibility":"visible",
		"z-index": zIndex - 1
	});
	disabledZone.setOpacity(0.3);
	$(el).setStyles({
		"position":"absolute",
		"z-index":zIndex,
		"visibility":"visible"
	});
	gewara.util.toCenter(el);
	if(pin) $(el).pin();
};
gewara.util.hideDialog = function(el){
	if($("dialogDisabledZone")) $("dialogDisabledZone").setStyle("visibility","hidden");
	if($(el)) $(el).setStyle("visibility", "hidden");
};
gewara.util.toCenter = function(src, target){
	var tar = $(target)||document.body,
	zIndex = $(src).getStyle("z-index");
   if(!zIndex || (zIndex < 10)) zIndex = 100;
   $(src).setStyles({
   	"position":"absolute",
      "z-index":zIndex,
      "visibility":"visible"
   });
   $(src).position({
   	relativeTo:tar,
   	position:"center"
   });
};
gewara.util.moveTo = function(src, target, xfloat, yfloat){
	if(!xfloat) xfloat=0;
	if(!yfloat) yfloat=0;
   var zIndex = $(src).getStyle("z-index");
   if(!zIndex || zIndex < 10) zIndex = 100;
   $(src).setStyles({
      "position":"absolute",
      "z-index":zIndex,
      "visibility":"visible"
   });
   $(src).position({
   	relativeTo:$(target),
   	position:"upperLeft",
   	offset:{x:xfloat,y:yfloat}
   });
   return this;   
};
gewara.util.moveToMouse = function(src, x, y){
   $(src).setStyles({
      "position":"absolute",
      "z-index":zIndex,
      "visibility":"visible"
   });
   $(src).position({
   	relativeTo:document.body,
   	position:"upperLeft"
   	//offset:{x:xfloat,y:yfloat}
   });
};
/*********************************************************
 * joinChar 将多个select、checkbox这样的多值用 joinChar连接起来
 **********************************************************/
gewara.util.getValues = function(elId, joinChar) {
  if (!$(elId)) return null;
  var values = $(elId).toQueryString().parseQueryString();
  if(!joinChar) return values;
  var hash = new Hash(values),result={};
  hash.each(function(value, key){
	  if(key) result[key] = (value && value.join) ? value.join(joinChar) : value;
  });
  return result;
};
gewara.util.getPostValues = function(elId){
  if (!$(elId)) return null;
  var values = $(elId).toQueryString().parseQueryString();
  return values;
}
/************************************************
 * 设置表单值（根据ID），不考虑MultiSelect，Radio，checkbox
 ************************************************/
gewara.util.setValues = function(data) {
  var hash = new Hash(data);
  hash.each(function(value, key){
	  if(key && $(key)) $(key).value = value;
  });
};
gewara.util.updateHtml = function(data, recordid){
  var hash = new Hash(data);
  hash.each(function(value, key){
	  if(key && $(key+"_"+recordid)) $(key+"_"+recordid).set("html", value);
  });
};
/*光标在元素内*/
gewara.util.inArea=function(el, x, y){
	var co = $(el).getCoordinates();
	return x>=co.left && x<=co.right && y>=co.top && y<=co.bottom;
};
/*光标不在元素内*/
gewara.util.outArea=function(el, x, y){
	var co = $(el).getCoordinates();
	return x<co.left || x>co.right || y<co.top || y>co.bottom;
};
gewara.util.show = function(item){
   try{item.setStyle("display","");}catch(e){};
};
gewara.util.hide = function(item){
   try{item.setStyle("display","none");}catch(e){};
};
gewara.util.openWindow = function(url,name,width,height,resizable,scrollbars,status){
   var top=20,left=120,win;
   if(window.screen.height){
      top=(window.screen.height-height)/2
   }
   if(window.screen.width){
      left=(window.screen.width-width)/2
   }
   win=window.open(url,name,"width="+width+",height="+height+",resizable="+(resizable?"yes":"no")+",scrollbars="+(scrollbars?"yes":"no")+",status="+(status?"1":"0")+",top="+top+",left="+left);
   if(win){win.focus();}
   return win;
};
gewara.util.sendRequest=function(url, values, callback, vmethod){
	var myRequest = new Request({
		url: url, method: vmethod||'post',
		onSuccess: function(resText){
			eval(resText);
			if(callback) callback.run(data);
		}
	});
	myRequest.send({'data':values});
};
gewara.util.sendLoad=function(el, url, values, callback){
	$(el).set('load', {data: values, evalScripts: true, onComplete: callback||function(){}});
	$(el).load(url);
};

gewara.util.slideIn = function(id){
	var slideElement = $(id); 
	var slideVar = new Fx.Slide(slideElement, { 
	mode: 'vertical',  
	transition: 'sine:in', 
	duration: 300
	});
	slideVar.slideIn();
}
gewara.util.removeAllOptions = function(elid){
	var selectel = $(elid);
	selectel.getElements("option").dispose();
}
gewara.util.addOptions = function(elid, dataList, valuefield, textfield){
	var selectel = $(elid),tmpValue, tmpText;
	dataList.each(function(item){
		if(valuefield instanceof Function) tmpValue = valuefiled.run(item);
		else tmpValue=item[valuefield];

		if(textfield instanceof Function) tmpText=textfield.run(item);
		else tmpText=item[textfield];

		new Element("option", {"value":tmpValue, "text":tmpText}).inject(selectel);
	})
}

function toggleDisplay(item){
   try{
      if($(item).getStyle("display")=="none") $(item).setStyle("display",""); else $(item).setStyle("display","none");
   }catch(e){}
}
/*  This function is to select all options in a multi-valued <select> */
function selectAll(elementId) {
   $(elementId).getElements("option").each(function(op){op.selected=true;});
}
var PanelGroup = new Class({
   tabList: [],
   initialize: function(vtabList, vcurrent, vactiveClass, vhideClass, vevent){
      this.activeClass = vactiveClass||"active";
      this.hideClass = vhideClass||"none";
		this.eventName = vevent||"click";
		this.current = vcurrent||"";
      var ac = this.activeClass, nc = this.hideClass, ve = this.eventName, panel = this;
      if(vcurrent && $(vcurrent)) {
         $(vcurrent).addClass(this.activeClass);
         $(vcurrent + "_content").removeClass(nc);
      }
      this.tableList=vtabList;
      vtabList.each(function(tab){
         if($(tab)){
	         $(tab).addEvent(ve, function(){
               if($(panel.current)){
                  $(panel.current).removeClass(ac);
	               $(panel.current+"_content").addClass(nc);
	            }
	            panel.current = tab;
	            $(tab).addClass(ac);
	            $(tab + "_content").removeClass(nc);
	         })
	      }
      });
   }
});
var ClassGroup = new Class({
   initialize: function(vtabList, vcurrent, vactiveClass, vhideClass){
      this.current = vcurrent||"";
      this.activeClass = vactiveClass||"active";
      this.hideClass = vhideClass||"none";
      this.tableList=vtabList;
      var ac = this.activeClass,panel = this;
      if(vcurrent) $(vcurrent).addClass(ac);
      vtabList.each(function(tab){
         if($(tab)){
            $(tab).addEvent("click", function(){
               if($(panel.current)) $(panel.current).removeClass(ac);
               panel.current = tab;
               $(tab).addClass(ac);
            })
         }
      });
   }
});

/******************
 * 调整图片最大宽度
 ******************/
function resizePicture(picList, maxWidth, galerie, vbasePath){
	var newHeight=0,newWidth=0,basePath=vbasePath||"/userfiles/";
	picList.each(function(img){
		var size = img.getSize();
		if(size.x > maxWidth || galerie){
			if(img.getParent().tagName != "A" && img.src.indexOf(basePath)>=0){
				img.inject(new Element("a",{
					"href":img.src,
					"rel":"lightbox[galerie]",
					"target":"_blank"
				}).inject(img, "before"));
			}
		}
		if(size.x > maxWidth){
			newHeight = size.y * maxWidth / size.x;
			newWidth = maxWidth;
			img.set("width", newWidth);
			img.set("height", newHeight);
			img.setStyles({"width":newWidth+"px", "height":newHeight+"px"});
		}
	});
}
function slidePicture(){
	var links = $$("a").filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	});
	$$(links).slimbox({/* Put custom options here */}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
}
function copyToClipboard(theField) {		
	var tempval=$(theField);		
	if (Browser.Engine.trident){
		tempval.select();		
		therange=tempval.createTextRange();
		therange.execCommand("Copy");
		alert("复制成功。现在您可以粘贴（Ctrl+v）到Blog 或BBS中了。");
		return;
	}else{
		alert("您使用的浏览器不支持此复制功能，请使用Ctrl+C或鼠标右键。");
		tempval.select();		
	}
}
function stopPropagation(event){
	event.stopPropagation();
}
function getFCKHtml(instance){
	var oEditor = FCKeditorAPI.GetInstance(instance);//获取当前页面 FCK 编辑器实例
	return oEditor.GetXHTML(); //获取编辑器内容
}
function getFCKText(instance, size){
	var oEditor = FCKeditorAPI.GetInstance(instance),
	text = $(oEditor.EditorDocument.body).get("text");
	if(size && text.length > size) return text.substring(0, size);
	return text;
}
function setFCKHtml(instance, vhtml){
	var oEditor = FCKeditorAPI.GetInstance(instance);//获取当前页面 FCK 编辑器实例
	return oEditor.SetHTML(vhtml); //获取编辑器内容
}
function removeFCKElement(instance, arrEl){
	var oEditor = FCKeditorAPI.GetInstance(instance),
	vbody = $(oEditor.EditorDocument.body);
	arrEl.each(function(item){vbody.getElements(item).dispose();});
}
function insertFCKHtml(instance, vhtml){
	var oEditor = FCKeditorAPI.GetInstance(instance);//获取当前页面 FCK 编辑器实例
	return oEditor.InsertHtml(vhtml);
}
function refreshPage(){
	var loc="" + document.location.href, idx = loc.indexOf("refresh"), anidx = loc.indexOf("#"), anchor="";
	if(anidx > 0){
		anchor = loc.substring(anidx);
		loc = loc.substring(0, anidx);
	}
	if(idx > 0){
		loc = loc.substring(0, idx - 1);
	}else{
		idx = loc.indexOf("?");
		if(idx > 0){
			loc=loc+"&refresh";
		}else{
			loc=loc+"?refresh";
		}
	}
	loc += anchor;
	document.location.href = loc;
}
/***********************************
*逐一翻滚代码
***********************************/
var runtopAndBottom = new Class({
	initialize:function(scrollId,maxh){
		this.isPause=false;
		this.maxScroll = $(scrollId).getScrollSize().y-$(scrollId).getSize().y;
		var _this=this, fn = function(){
			if(!_this.isPause){
				_this.fx.start(0, $(scrollId).getScroll().y+maxh);
			}
		};
		this.fx = new Fx.Scroll(scrollId, {
			duration: 500, transition: Fx.Transitions.Sine.easeOut,
			onComplete: function(){
				if($(scrollId).getScroll().y == _this.maxScroll) this.set(0,0);
    		}
		});
		$(scrollId).addEvents({
			"mouseover":function(){_this.isPause = true;},
			"mouseout":function(){_this.isPause = false;}
		});
		fn.periodical(3000);
	}
});
/*********************
 * check Logon Member
 *********************/
function checkLogin(show, successCallback, cancleCallback){
	if(!cancleCallback) cancleCallback=function(){};
	GewaraUtil.sendRequest(GewaraUtil.basePath+"ajax/common/checkLogon.xhtml",{}, function(result){
		if(result.success){
			successCallback();
		}else{
			if(show) showLogin(successCallback, cancleCallback);
		}
	});
}
/**********************************************
 * check Logon GewaraUser, 可能是Member或User
 **********************************************/
function checkUserLogin(show, callback, cancleCallback){
	if(!cancleCallback) cancleCallback=function(){};
	GewaraUtil.sendRequest(GewaraUtil.basePath+"ajax/common/checkUserLogon.xhtml",{}, function(result){
		if(result.success){
			callback();
		}else{
			if(show) showLogin(callback, cancleCallback);
		}
	});
}
function gotoPosition(elid){
	if($(elid)) $(window).scrollTo(0,$(elid).getPosition().y);
}


var DefaultValue = new Class({
	initialize: function(el, disp){
		$(el).value = disp;
		$(el).addEvents({
			'blur':function(){
				if(this.value.trim() == "") this.value = disp;
			},
			'focus':function(){
				if(this.value.trim() == disp) this.value="";
			}
		});
	}
});

/*****
**分享好友动态链接
**/
function share(title,value,pic,tag,tagid,type){
	checkLogin(true, function(){
		var url=GewaraUtil.basePath+"linkKaiXin.xhtml?title="+encodeURIComponent(title)+"&value="+encodeURIComponent(value)+"&pic="+encodeURIComponent(pic)+"&tag="+tag+"&tagid="+tagid+"&type="+type;
		new Request({url:url,method:'get',
				onSuccess:function(resText){
					eval(resText)
					if(data.success){
						if(type=='kaixin'){
							 try{
					         var pageTracker = _gat._getTracker("UA-1810182-1");
					         pageTracker._setDomainName("none");
					         pageTracker._setAllowLinker(true);
								pageTracker._trackPageview('/kaixin/fenxiang/');
					      }catch(e){}
						}
						window.location.target="_this";
						window.location.href=data.linkUrl;
						//window.open(data.linkUrl,'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
					}
				}
		}).send();
	});
}
/***
**分享帖子
***/
function shareTopic(title,value,tag,tagid,type){
		checkLogin(true, function(){
			var url=GewaraUtil.basePath+"topicLinkKaiXin.xhtml?title="+encodeURIComponent(title)+"&content="+encodeURIComponent(value+"...")+"&tag="+tag+"&tagid="+tagid+"&type="+type;
			new Request({url:url,method:'get',
							onSuccess:function(resText){
								eval(resText)
								if(data.success){
									if(type=='kaixin'){
										try{
							         	var pageTracker = _gat._getTracker("UA-1810182-1");
							         	pageTracker._setDomainName("none");
							         	pageTracker._setAllowLinker(true);
											pageTracker._trackPageview('/kaixin/fenxiang/');
							      	}catch(e){}									
									}
									window.open(data.linkUrl,'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
								}							
							}
			}).send();
		});
}

/**
**分享到豆瓣
***/
function toDouban(){
		var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'';
		r='http://www.douban.com/recommend/?url='+e(d.location.href)+'&title='+e(d.title)+'&sel='+e(s)+'&v=1',
		x=function(){
		  if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'
		};
      if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}
}

/**
**分享到新浪
***/
function toSina(encoding, vtitle, vurl, referer,pic){
   	var s=screen,d=document,e=encodeURIComponent;
   	var XXXX = vtitle;
   	var YYYY=pic;
   	var f='http://v.t.sina.com.cn/share/share.php?appkey=2924220432',u=vurl||d.location;
   	var p=['&url=',e(u),'&title=', e(XXXX||d.title), '&content=', encoding||'utf-8', '&pic=', YYYY].join('');
   	a = function(){if(!window.open([f,p].join(''),'mb',['toolbar=1,status=1,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};
   	if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();
}

/**
**分享到人人
***/
function toRenRen(){
	window.open('http://share.renren.com/share/buttonshare.do?title='+encodeURIComponent(document.title.substring(0,76))+'&link='+encodeURIComponent(location.href)+'&content=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
}

/**
**添加关注人(项目场馆)
***/
function addMemberTreasure(memberid,tag,obj){
	checkLogin(true, function(){
		var url = GewaraUtil.basePath + "wala/addMicroAttention.xhtml";
		new Request({
			url:url,
			method:'post',
			onSuccess:function(resText){
				eval(resText);
				if(data.success){
					if(tag == 'micro'){
						if($chk(obj)&&$chk(obj.getParent('span')))
							obj.getParent('span').set('text','已关注').addClass('gray');
						else refreshPage();
					}else{
						alert(data.retval);
					}
				}else{
		 			alert(data.msg);
				}
				
			}
		}).send({'data':{'memberid':memberid}});
	});
}


/**
**发表哇啦，一句话点评字数提示
***/
function microChange(obj){
	var num=140;
	if($chk($(obj).value)){
		var num = 140-$(obj).value.length;
	}
	if(num<0){ 
		var value = Math.abs(num);
		$('microText').set('styles',{'color':'#C03B0C'});
		$('microText').set('html','已超出<b style="font-size:15px;font-family: Constantia,Georgia" id="font">'+value+'</b>个汉字');
	}else{
		$('microText').set('styles',{'color':'black'}).set('html','你还可以输入<b style="font-size:15px;font-family: Constantia,Georgia" id="font">'+num+'</b>个字');
	}
}

/**
**判断当前用户是否被管理员加入黑名单
**/
function isCommuBlack(commuid, loc){
	var url = GewaraUtil.basePath+"home/commu/isCommuBlack.xhtml";
	var values = {'commuid':commuid};
	return GewaraUtil.sendRequest(url,values,function(result){
		if(result.success){
			if(loc){window.document.location = loc;}
		}
		else{
		 alert(result.msg);
		}
	});
}

/**
*	话剧明星 - 成为fans
*/
function addFans(obj, relatedid, tag){
	var url = GewaraUtil.basePath + 'ajax/common/tobeFans.xhtml';
	var values = {'relatedid':relatedid, 'tag':tag};
	GewaraUtil.sendRequest(url, values, function(result){
		if(result.success){
			alert("已添加成功!");
		}else{
			alert(result.msg);
		}
	})
	$(obj).removeEvent('click', addFans);
}

/**
**解除好友关系
**/
function removeFriendRelate(memberid){
	if(confirm("解除好友关系从好友列表中删除，确认删除吗？")){
		var url = GewaraUtil.basePath + 'wala/removeFriend.xhtml';
		var values = {'memberid':memberid};
		GewaraUtil.sendRequest(url,values,function(result){
			if(result.success){
				refreshPage();
			}else{
				alert(result.msg);
			}
		});
	}
}


